home *** CD-ROM | disk | FTP | other *** search
- #!/bin/bash
- ######################################################################
- # #
- # Sample script for 24U Appearance OSAX 3.1 #
- # Copyright ©2000-2006 24U Software #
- # #
- # This sample script shows how to use message windows from within #
- # command line environment to show the progress of a shell script #
- # #
- # (Requires bash which is part of Mac OS X since version 10.2 !!!) #
- # #
- ######################################################################
-
- #
- # first, open a global message window. if it was not global it was
- # closed after osascript had terminated. store osascript's result
- # into variable RESULT
- #
- RESULT=`osascript -e 'create message window "Determining the number of files to synchronize..." with properties {global window:true, closeable:true}'`
-
-
-
- #
- # check the result and if everything was ok, then remember Window ID
- # property of returned record. it is enough to reference a window.
- #
- if [ $? == 0 ]; then
- WINDOWID=`echo $RESULT | cut -f 1 -d , | cut -f 2 -d :`
- else
- echo Error openening window...
- exit 1
- fi
-
- echo "24U Appearance OSAX's message window opened."
- sleep 2
-
-
- #
- # update the message window with some new text. we have to
- # construct script with WINDOWID variable. the script should
- # be:
- #
- # update progress indicator $WINDOWID message text "new text"
- #
- # since we haven't got an error while we was creating the
- # message window, we are no more interested in osascript's
- # result.
- #
- SCRIPT="update message window $WINDOWID message text \"Synchronizing files...\""
- osascript -e "$SCRIPT" >/dev/null
- echo "24U Appearance OSAX's message window updated."
-
-
- #
- # count the number of files in your home directory and store
- # them into COUNT variable and the files theyself into FILES.
- #
- COUNT=`ls -1A ~ | wc -l`
- FILES=`ls -1A ~`
-
-
- #
- # update message window for each file in FILES variable.
- #
- for i in $FILES; do
- SCRIPT="update message window $WINDOWID message text \"Synchronizing file $i...\"";
- osascript -e "$SCRIPT" >/dev/null;
- echo "24U Appearance OSAX's message window updated again.";
- done
-
-
- #
- # update message window with the "Synchronization done..." text
- #
- SCRIPT="update message window $WINDOWID message text \"Synchronization done...\"";
- osascript -e "$SCRIPT" >/dev/null;
- echo "24U Appearance OSAX's message window updated again.";
-
- sleep 2
-
- #
- # close the message window and exit script
- #
- SCRIPT="close message window $WINDOWID"
- osascript -e "$SCRIPT" >/dev/null
-
- echo "24U Appearance OSAX's message window closed."
-